<template>
	<view class="content">
		<view class="city">
			<view class="item" v-for="(city,index) in citys" :key="index" v-if="city.id == id" @click="checkcity(city.name)">
				<view class="text">{{city.name}}</view>
				<image class="arrow" src="../../static/images/ic_arrow_right.png">
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '', // 省的名字
				id: '', // 城市的id
				uid: '', // 用户uid
				citys: [
					{name:'安庆', id:'01'}, {name:'蚌埠', id:'01'}, {name:'亳州', id:'01'},{name:'滁州', id:'01'}, {name:'埠阳', id:'01'},{name:'合肥', id:'01'},{name:'淮北', id:'01'},{name:'淮南', id:'01'},{name:'黄山', id:'01'},{name:'六安', id:'01'},{name:'马鞍山', id:'01'},{name:'宿州', id:'01'},{name:'铜陵', id:'01'},{name:'芜湖', id:'01'},{name:'宣城', id:'01'},
					{name:'昌平', id:'02'},{name:'朝阳', id:'02'},{name:'大兴', id:'02'},{name:'东城', id:'02'},{name:'房山', id:'02'},{name:'丰台', id:'02'},{name:'海淀', id:'02'},{name:'怀柔', id:'02'},{name:'门沟头', id:'02'},{name:'密云', id:'02'},{name:'平谷', id:'02'},{name:'石景山', id:'02'},{name:'顺义', id:'02'},
					{name:'巴南', id:'03'},{name:'北碚', id:'03'},{name:'璧山', id:'03'},{name:'长寿', id:'03'},{name:'城口', id:'03'},{name:'大渡口', id:'03'},{name:'大足区', id:'03'},{name:'垫江', id:'03'},{name:'丰都', id:'03'},{name:'奉节', id:'03'},{name:'涪陵', id:'03'},{name:'合川', id:'03'},{name:'江北', id:'03'},{name:'江津', id:'03'},{name:'九龙坡', id:'03'},{name:'开州区', id:'03'},{name:'两江新区', id:'03'},{name:'梁平', id:'03'},{name:'南岸', id:'03'},{name:'彭水', id:'03'},{name:'綦江区', id:'03'},{name:'黔江', id:'03'},{name:'荣昌', id:'03'},{name:'沙坪坝', id:'03'},{name:'石柱', id:'03'},{name:'铜梁', id:'03'},{name:'潼南', id:'03'},{name:'万州', id:'03'},{name:'武隆', id:'03'},{name:'巫山', id:'03'},{name:'巫溪', id:'03'},{name:'秀山', id:'03'},{name:'永川', id:'03'},{name:'酉阳', id:'03'},{name:'渝北', id:'03'},{name:'云阳', id:'03'},{name:'忠县', id:'03'},
					{name:'福州', id:'04'},{name:'龙岩', id:'04'},{name:'南平', id:'04'},{name:'宁德', id:'04'},{name:'莆田', id:'04'},{name:'泉州', id:'04'},{name:'三明', id:'04'},{name:'厦门', id:'04'},{name:'漳州', id:'04'},
					{name:'白银', id:'05'},{name:'定西', id:'05'},{name:'甘南', id:'05'},{name:'嘉峪关', id:'05'},{name:'金昌', id:'05'},{name:'酒泉', id:'05'},{name:'兰州', id:'05'},{name:'临夏', id:'05'},{name:'陇南', id:'05'},{name:'平凉', id:'05'},{name:'庆阳', id:'05'},{name:'天水', id:'05'},{name:'武威', id:'05'},{name:'张掖', id:'05'},
					{name:'潮州', id:'06'},{name:'东莞', id:'06'},{name:'佛山', id:'06'},{name:'广州', id:'06'},{name:'河源', id:'06'},{name:'惠州', id:'06'},{name:'江门', id:'06'},{name:'揭阳', id:'06'},{name:'茂名', id:'06'},{name:'梅州', id:'06'},{name:'清远', id:'06'},{name:'汕头', id:'06'},{name:'汕尾', id:'06'},
					{name:'白色', id:'07'},{name:'北海', id:'07'},{name:'崇左', id:'07'},{name:'防城港', id:'07'},{name:'贵港', id:'07'},{name:'桂林', id:'07'},{name:'河池', id:'07'},{name:'贺州', id:'07'},{name:'来宾', id:'07'},{name:'柳州', id:'07'},{name:'南宁', id:'07'},{name:'钦州', id:'07'},{name:'梧州', id:'07'},{name:'玉林', id:'07'},
					{name:'安顺', id:'08'},{name:'毕节', id:'08'},{name:'贵阳', id:'08'},{name:'六盘水', id:'08'},{name:'黔东南', id:'08'},{name:'黔南', id:'08'},{name:'黔西南', id:'08'},{name:'同仁', id:'08'},{name:'遵义', id:'08'},
					{name:'白沙', id:'09'},{name:'保亭', id:'09'},{name:'昌江', id:'09'},{name:'澄迈', id:'09'},{name:'儋州', id:'09'},{name:'安定', id:'09'},{name:'东方', id:'09'},{name:'海口', id:'09'},{name:'乐东', id:'09'},{name:'临高', id:'09'},{name:'陵水', id:'09'},{name:'琼海', id:'09'},{name:'琼中', id:'09'},{name:'三沙', id:'09'},{name:'三亚', id:'09'},{name:'屯昌', id:'09'},{name:'万宁', id:'09'},{name:'文昌', id:'09'},{name:'五指山', id:'09'},
					{name:'保定', id:'10'},{name:'沧州', id:'10'},{name:'承德', id:'10'},{name:'邯郸', id:'10'},{name:'衡水', id:'10'},{name:'廊坊', id:'10'},{name:'秦皇岛', id:'10'},{name:'石家庄', id:'10'},{name:'唐山', id:'10'},{name:'邢台', id:'10'},{name:'张家口', id:'10'},
					{name:'安阳', id:'11'},{name:'鹤壁', id:'11'},{name:'济源', id:'11'},{name:'焦作', id:'11'},{name:'开封', id:'11'},{name:'洛阳', id:'11'},{name:'南阳', id:'11'},{name:'平顶山', id:'11'},{name:'濮阳', id:'11'},{name:'三门峡', id:'11'},{name:'商丘', id:'11'},{name:'漯河', id:'11'},{name:'新乡', id:'11'},
					{name:'大庆', id:'12'},{name:'大兴安岭', id:'12'},{name:'哈尔滨', id:'12'},{name:'鹤岗', id:'12'},{name:'黑河', id:'12'},{name:'鸡西', id:'12'},{name:'佳木斯', id:'12'},{name:'牡丹江', id:'12'},{name:'齐齐哈尔', id:'12'},{name:'七台河', id:'12'},{name:'双鸭山', id:'12'},{name:'绥化', id:'12'},{name:'伊春', id:'12'},
					{name:'鄂州', id:'13'},{name:'恩施', id:'13'},{name:'黄冈', id:'13'},{name:'黄石', id:'13'},{name:'荆门', id:'13'},{name:'潜江', id:'13'},{name:'神农架', id:'13'},{name:'十堰', id:'13'},{name:'随州', id:'13'},{name:'天门', id:'13'},{name:'武汉', id:'13'},{name:'咸宁', id:'13'},{name:'仙桃', id:'13'},{name:'襄阳', id:'13'},{name:'孝感', id:'13'},{name:'宜昌', id:'13'},
					{name:'常德', id:'14'},{name:'长沙', id:'14'},{name:'郴州', id:'14'},{name:'衡阳', id:'14'},{name:'怀化', id:'14'},{name:'娄底', id:'14'},{name:'邵阳', id:'14'},{name:'湘潭', id:'14'},{name:'湘西', id:'14'},{name:'益阳', id:'14'},{name:'永州', id:'14'},{name:'岳阳', id:'14'},{name:'张家界', id:'14'},
					{name:'白城', id:'15'},{name:'白山', id:'15'},{name:'长春', id:'15'},{name:'吉林', id:'15'},{name:'辽源', id:'15'},{name:'四平', id:'15'},{name:'松原', id:'15'},{name:'通化', id:'15'},{name:'延边', id:'15'},
					{name:'常州', id:'16'},{name:'淮安', id:'16'},{name:'连云港', id:'16'},{name:'南京', id:'16'},{name:'南通', id:'16'},{name:'宿迁', id:'16'},{name:'苏州', id:'16'},{name:'泰州', id:'16'},{name:'无锡', id:'16'},{name:'徐州', id:'16'},{name:'盐城', id:'16'},{name:'扬州', id:'16'},{name:'镇江', id:'16'},
					{name:'抚州', id:'17'},{name:'赣州', id:'17'},{name:'吉安', id:'17'},{name:'景德镇', id:'17'},{name:'九江', id:'17'},{name:'南昌', id:'17'},{name:'萍乡', id:'17'},{name:'上饶', id:'17'},{name:'新余', id:'17'},{name:'宜春', id:'17'},{name:'鹰潭', id:'17'},
					{name:'鞍山', id:'18'},{name:'本溪', id:'18'},{name:'朝阳', id:'18'},{name:'大连', id:'18'},{name:'丹东', id:'18'},{name:'抚顺', id:'18'},{name:'阜新', id:'18'},{name:'葫芦岛', id:'18'},{name:'锦州', id:'18'},{name:'辽阳', id:'18'},{name:'盘锦', id:'18'},{name:'沈阳', id:'18'},{name:'铁岭', id:'18'},{name:'营口', id:'18'},
					{name:'阿拉善', id:'19'},{name:'巴彦淖尔', id:'19'},{name:'包头', id:'19'},{name:'赤峰', id:'19'},{name:'鄂尔多斯', id:'19'},{name:'呼和浩特', id:'19'},{name:'呼伦贝尔', id:'19'},{name:'通辽', id:'19'},{name:'乌海', id:'19'},{name:'乌兰察布', id:'19'},{name:'锡林郭勒', id:'19'},{name:'兴安', id:'19'},
					{name:'固原', id:'20'},{name:'石嘴山', id:'20'},{name:'吴忠', id:'20'},{name:'银川', id:'20'},{name:'中卫', id:'20'},
					{name:'果洛', id:'21'},{name:'海北', id:'21'},{name:'海东', id:'21'},{name:'海南', id:'21'},{name:'海西', id:'21'},{name:'黄南', id:'21'},{name:'西宁', id:'21'},{name:'玉树', id:'21'},
					{name:'安康', id:'22'},{name:'宝鸡', id:'22'},{name:'汉中', id:'22'},{name:'商洛', id:'22'},{name:'铜川', id:'22'},{name:'渭南', id:'22'},{name:'西安', id:'22'},{name:'咸阳', id:'22'},{name:'延安', id:'22'},{name:'榆林', id:'22'},
					{name:'滨州', id:'23'},{name:'德州', id:'23'},{name:'东营', id:'23'},{name:'菏泽', id:'23'},{name:'济南', id:'23'},{name:'济宁', id:'23'},{name:'莱芜区', id:'23'},{name:'聊城', id:'23'},{name:'临沂', id:'23'},{name:'青岛', id:'23'},{name:'日照', id:'23'},{name:'泰安', id:'23'},{name:'潍坊', id:'23'},{name:'威海', id:'23'},{name:'烟台', id:'23'},{name:'枣庄', id:'23'},{name:'淄博', id:'23'},
					{name:'长治', id:'24'},{name:'大同', id:'24'},{name:'晋城', id:'24'},{name:'晋中', id:'24'},{name:'临汾', id:'24'},{name:'吕梁', id:'24'},{name:'朔州', id:'24'},{name:'太原', id:'24'},{name:'忻州', id:'24'},{name:'阳泉', id:'24'},{name:'运城', id:'24'},
					{name:'宝山', id:'25'},{name:'长宁', id:'25'},{name:'崇明', id:'25'},{name:'奉贤', id:'25'},{name:'虹口', id:'25'},{name:'黄浦', id:'25'},{name:'嘉定', id:'25'},{name:'金山', id:'25'},{name:'静安', id:'25'},{name:'闵行', id:'25'},{name:'浦东新区', id:'25'},{name:'普陀', id:'25'},{name:'青浦', id:'25'},{name:'松江', id:'25'},{name:'徐汇', id:'25'},{name:'杨浦', id:'25'},
					{name:'阿坝', id:'26'},{name:'巴中', id:'26'},{name:'成都', id:'26'},{name:'达州', id:'26'},{name:'德阳', id:'26'},{name:'甘孜', id:'26'},{name:'广安', id:'26'},{name:'广元', id:'26'},{name:'乐山', id:'26'},{name:'凉山', id:'26'},{name:'泸州', id:'26'},{name:'眉山', id:'26'},{name:'绵阳', id:'26'},{name:'南充', id:'26'},{name:'内江', id:'26'},{name:'攀枝花', id:'26'},{name:'遂宁', id:'26'},{name:'雅安', id:'26'},{name:'宜宾', id:'26'},{name:'自贡', id:'26'},{name:'资阳', id:'26'},
					{name:'宝坻', id:'27'},{name:'北辰', id:'27'},{name:'滨海新区', id:'27'},{name:'东丽', id:'27'},{name:'河北', id:'27'},{name:'河东', id:'27'},{name:'和平', id:'27'},{name:'河西', id:'27'},{name:'红桥', id:'27'},{name:'蓟州', id:'27'},{name:'津南', id:'27'},{name:'静海', id:'27'},{name:'南开', id:'27'},{name:'宁河', id:'27'},{name:'武清', id:'27'},{name:'西青', id:'27'},
					{name:'阿里', id:'28'},{name:'昌都', id:'28'},{name:'拉萨', id:'28'},{name:'林芝', id:'28'},{name:'那曲', id:'28'},{name:'日喀则', id:'28'},{name:'山南', id:'28'},
					{name:'阿克苏', id:'29'},{name:'阿拉尔', id:'29'},{name:'阿勒泰', id:'29'},{name:'巴音郭楞', id:'29'},{name:'博尔塔拉', id:'29'},{name:'昌吉', id:'29'},{name:'哈密', id:'29'},{name:'和田', id:'29'},{name:'喀什', id:'29'},{name:'克拉玛依', id:'29'},{name:'克孜勒苏', id:'29'},{name:'石河子', id:'29'},{name:'塔城', id:'29'},{name:'吐鲁番', id:'29'},{name:'图木舒克', id:'29'},{name:'五家渠', id:'29'},{name:'乌鲁木齐', id:'29'},{name:'伊犁', id:'29'},
					{name:'宝山', id:'30'},{name:'楚雄', id:'30'},{name:'大理', id:'30'},{name:'德宏', id:'30'},{name:'迪庆', id:'30'},{name:'红河', id:'30'},{name:'昆明', id:'30'},{name:'丽江', id:'30'},{name:'临沧', id:'30'},{name:'怒江', id:'30'},{name:'普洱', id:'30'},{name:'曲靖', id:'30'},{name:'文山', id:'30'},{name:'西双版纳', id:'30'},{name:'玉溪', id:'30'},{name:'昭通', id:'30'},
					{name:'杭州', id:'31'},{name:'湖州', id:'31'},{name:'嘉兴', id:'31'},{name:'金华', id:'31'},{name:'丽水', id:'31'},{name:'宁波', id:'31'},{name:'衡州', id:'31'},{name:'绍兴', id:'31'},{name:'台州', id:'31'},{name:'温州', id:'31'},{name:'舟山', id:'31'}
				]
			}
		},
		onLoad(option) {			
			this.id = option.id;
			this.uid = option.uid;
			this.name = option.name;
		},
		methods: {
			// 选择子城市
			checkcity(name) {
				console.log(this.name + name);
				uni.request({
					url: 'https://www.yedushu.cn/api/savecity', // 保存设置的城市
					method:'POST',
					data: {
						uid: this.uid,
						sheng: this.name,
						shi: name
					},
					success: (res) => {
						// console.log(JSON.stringify(res.data.code));
						if(res.data.code == 1) {
							// 修改成功
							var userinfo = uni.getStorageSync('userinfo');
							// console.log(JSON.stringify(userinfo));
							userinfo['province'] = this.name; // 设置对象中的值，省名
							userinfo['city'] = name; // 设置对象中的值，市名
							uni.setStorageSync('userinfo', userinfo);  // 重新存储到本地
							// console.log(JSON.stringify(userinfo));							
							// 触发资料与帐号设置（setmyselft.vue）页上的事件，更新性别
							uni.$emit("setcity",{
									sheng: this.name,
									shi: name
								},
							);
							// 返回到上一页面
							uni.navigateBack({
							    delta: 2
							});
						}
					}
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		padding: 10px 10px;
	}
	.item {
		padding: 5px 0;
		border-bottom: solid 1px #F2F2F2;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.text {
		font-size: 15px;
		padding: 10px 0;
	}
	.arrow {
		width: 7px;
		height: 12px;
	}
</style>
